
using Microsoft.Xna.Framework;
using Tama_Chan.Entities_ns;


namespace Tama_Chan.AI
{
   public static class SteeringBehaviors
   {
      /// <summary>
      /// The steering force returned by this method is the force required, which when
      /// added to the agent's current velocity gives the desired velocity.
      /// </summary>
      public static Vector2 Seek(GameEntity seeker, GameEntity target)
      {
         // Get the ideal velocity if the agent was sitting still.
         var desiredVelocity = Vector2.Normalize(target.Position - seeker.Position) * seeker.Speed;

         // Agent is NOT sitting still, so get the velocity needed to adjust agent's current velocity.
         return desiredVelocity - seeker.Velocity;
      }


      public static Vector2 Seek(GameEntity seeker, Vector2 target)
      {
         // Get the ideal velocity if the agent was sitting still.
         var desiredVelocity = Vector2.Normalize(target - seeker.Position) * seeker.Speed;

         // Agent is NOT sitting still, so get the velocity needed to adjust agent's current velocity.
         return desiredVelocity - seeker.Velocity;
      }


      public static Vector2 SeekWithTurnSpeed(GameEntity seeker, float turnSpeed, GameEntity target)
      {
         Vector2 seekVelocity = Seek(seeker, target);
         float length = seekVelocity.Length();
         if(length > turnSpeed)
         {
            seekVelocity = Vector2.Multiply(Vector2.Normalize(seekVelocity), turnSpeed);
         }
         return seekVelocity;
      }


      public static Vector2 Pursuit(GameEntity pursuer, GameEntity evader)
      {
         return Vector2.One;
      }

   }
}
